package com.ruoyi.system.controller;


import com.ruoyi.system.domain.Chunk;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lichunsheng.minio.MinioTemplate;
import top.lichunsheng.vo.CreateMultipartUploadResultVO;


import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author : 赵贤
 * @create: 2023-03-10 09:24
 * @Description:
 */
@RestController
@RequestMapping("file")
@CrossOrigin
public class FileController {

    @Resource
    MinioTemplate minioTemplate;

    @RequestMapping("upload")
    public void upload(@ModelAttribute Chunk chunk){

        CreateMultipartUploadResultVO multipartUpload = minioTemplate.createMultipartUpload(chunk.getIdentifier(), chunk.getFilename(), chunk.getTotalChunks());
        minioTemplate.completeMultipartUpload("/mp4",multipartUpload.getUploadId());
    }

}
